package com.august.task;

import com.august.utils.SpringContextUtil;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.concurrent.Callable;

public class MysqlInsertTask implements Callable<Integer> {

    private int start;
    private int end;

    public MysqlInsertTask(int start,int end) {
        this.start = start;
        this.end = end;
    }


    @Override
    public Integer call() throws Exception {
        JdbcTemplate mysql1JdbcTemplate = SpringContextUtil.getBean("mysql1JdbcTemplate");

        String sql="insert into student(name,age) values ('zhangsan',10)";
        //long begin = System.currentTimeMillis();

        for(int i=start;i<end;i++){
            mysql1JdbcTemplate.batchUpdate(sql);
        }

      //  long end = System.currentTimeMillis();

        return 1;
    }
}
